package com.bifrost.service.impl;

import com.bifrost.entity.MerchantStore;
import com.bifrost.entity.SystemHelpcenter;
import com.bifrost.repository.SystemHelpcenterRepository;
import com.bifrost.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

/**
 * @author rangf
 * @date 2018/1/17
 */
@Service
public class SystemServiceImpl implements SystemService {

    @Autowired
    SystemHelpcenterRepository systemHelpcenterRepository;

    @Override
    public SystemHelpcenter getSystemHelp(Long systemHelpcenterId) {
        return systemHelpcenterRepository.findOne(systemHelpcenterId);
    }

    /**
     * 获取门店指定代码的帮助中心内容
     *
     * @param store
     * @param code
     * @return
     */
    @Override
    public SystemHelpcenter getSystemHelp(MerchantStore store, String code) {
        Assert.notNull(store,"门店不能为空");
        Assert.hasText(code,"代码不能为空");
        return systemHelpcenterRepository.findFirstByMerchantIdAndCode(store.getMerchantId(),code);
    }
}
